#! /bin/csh -f

set RM = /bin/rm
set TOUCH = /bin/touch
set MV = /bin/mv
set LN = /bin/ln
set CP = /bin/cp

# //////////////////////////////////////////////////////////////////////////
echo "==================================================================="
echo "Date: `date`"

if ( -l /usr/spool ) then
   echo "/usr/spool is already a link. Done."
   exit 0
endif

if ( ! -d /var/spool/es ) then
   mkdir /var/spool/es
endif

# Now test if /usr/spool/es is a link
if ( -l /usr/spool/es ) then
   ${RM} -f /usr/spool/es
else
   if ( -d /usr/spool/es ) then
        echo "/usr/spool/es directory exist..."
	foreach i (`ls /usr/spool/es`)
	    echo "  -- Copying file/dir= $i to /var/spool/es..."
	    ${CP} -r /usr/spool/es/$i /var/spool/es
	    if ( $status != 0 ) then
		echo "== Copying files failed.. "
		echo "== Please refer to elec_svcs_callsvr relnotes chapter 2.6"
		exit 1
	    endif
        end
	echo "== Files have been copied from /usr/spool/es to /var/spool/es."
	${RM} -fr /usr/spool/es
	echo "== Old /usr/spool/es has been removed."
   endif
endif
   
if ( -s /usr/spool/es ) then
	${MV} /usr/spool/es /usr/spool/es/.old
endif
 
if ( ! -d /usr ) then
	mkdir /usr 
endif

if ( ! -d /usr/spool ) then
	mkdir /usr/spool
endif
   
${LN} -s ../../var/spool/es /usr/spool/es
   
echo "Done."
